package com.medical.client.controller.unit;


import com.medical.client.controller.RootController;
import com.medical.client.model.Context;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

/**
 * @ClassName: HBoxController
 * @Description: TODO
 * @Author: JackyLee
 * @Date: 2024/5/27 21:25
 **/
public class GridController extends RootController {

    @FXML
    TextField tx;

    @FXML
    Button queryBtu;

    @FXML
    Button uploadBtu;

    @FXML
    CheckBox cb;

    @FXML
    public void queryBtu() {
        BorderController functionController = (BorderController) Context.controllers.get("com.medical.client.controller.unit.BorderController");
        System.out.println("Button clicked!");
        String unitName = tx.getText();
        functionController.setData(unitName);
        // Add your custom code here to perform actions when the button is clicked
    }

    @FXML
    public void clearBtu() {
        System.out.println("clear");
        BorderController functionController = (BorderController) Context.controllers.get("com.medical.client.controller.unit.BorderController");
        functionController.clearData();
        tx.clear();
        // Add your custom code here to perform actions when the button is clicked
    }

    @FXML
    public void checkBtu() {
        Context.checkBox.put("unit",cb.isSelected());
    }

    @FXML
    public void uploadBtu(){
        System.out.println("uploadBtu");
        BorderController functionController = (BorderController) Context.controllers.get("com.medical.client.controller.unit.BorderController");
        functionController.uploadData();
        tx.clear();
    }

    public void setBtu(Boolean isUse){
        queryBtu.setDisable(isUse);
        uploadBtu.setDisable(isUse);
    }
}
